<extend name="Public/base" />

<block name="body">
  <!-- 标题栏 -->
  <div class="main-title">
    <h2>第二件折扣管理</h2>
  </div>
  
  <div class="cf">
      <div class="search-form fr cf">
          <input type="text" name="store" class="search-input w-260" value="{:I('store')}" placeholder="店铺名称">
          <a class="sch-btn" href="javascript:;" id="search" url="{:U()}"><i class="btn-search"></i></a>
      </div>
  </div>
  <!-- 数据列表 -->
  <div class="data-table table-striped">
    <table class="">
      <thead>
        <tr>
          <!-- <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th> -->
          <th>活动名称</th>
          <th>活动时间</th>
          <th>活动商品</th>
          <th>活动折扣</th>
          <th>活动来源</th>
          <th>活动状态</th>
          <th width="140" class="text-center">操作</th>
        </tr>
      </thead>
      <tbody>
      <notempty name="lists">
        <volist name="lists" id="vo">
          <tr class="status_trclass_{$vo.status}">
            <!-- <td><input class="ids" type="checkbox" name="ids[]" value="{$vo.id}" /></td> -->
            <td><eq name="vo.store_id" value="0"><a href="{:U('edit?id='.$vo['id'])}">{$vo.name}</a><else/>{$vo.name}</eq> </td>
            <td>{:time_format($vo['start_time'], 'Y-m-d')} 至 {:time_format($vo['expire_time'], 'Y-m-d')} 23:59:59</td>
            <td><a href="{:U('/Item/detail?id='.$vo['item_id'])}"  target="_blank">{$vo.item_id|get_item_name}</a></td>
            <td>{$vo.discount}</td>
            <php>$member_id = get_store_member_id($vo['store_id']);</php>
            <td><gt name="member_id" value="0"><a href="{:U('Store/detail?member_id='.$member_id)}">{:store_name($vo['store_id'])}</a><else />{:store_name($vo['store_id'])}</gt></td>
              <td>
                  <if condition="$vo['start_time'] gt NOW_TIME">
                      <span class="text-danger">（未开始）</span>
                      <else/>
                      <if condition="$vo['expire_time'] gt NOW_TIME">
                          <span class="text-success">（进行中）</span>
                          <else/>
                          <span class="text-cancel">（已过期）</span>
                      </if>
                  </if>
              </td>
            <td class="text-center">
              <eq name="vo.status" value="1">
                <eq name="vo.store_id" value="0"><a href="{:U('setStatus?status=0&ids='.$vo['id'])}" class="ajax-get">[禁用]</a><else /><span class="disabled">[禁用]</span></eq>
              <else/>
                <eq name="vo.store_id" value="0"><a href="{:U('setStatus?status=1&ids='.$vo['id'])}" class="ajax-get">[启用]</a><else /><span class="disabled">[启用]</span></eq>
              </eq>
              <eq name="vo.store_id" value="0"><a href="{:U('edit?id='.$vo['id'])}">[编辑]</a><else /><span class="disabled">[编辑]</span></eq>
              <eq name="vo.store_id" value="0"><a href="{:U('setStatus?status=-1&ids='.$vo['id'])}" class="confirm ajax-get">[删除]</a><else /><span class="disabled">[删除]</span></eq>
            </td>
          </tr>
        </volist>
        <else/>
        <td colspan="12" class="text-center"> aOh! 暂时还没有内容! </td>
      </notempty>
      </tbody>
    </table>

  </div>
  <div class="page">
    {$_page}
  </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function(){
            //搜索功能
            $("#search").click(function(){
                var url = $(this).attr('url');
                var query  = $('.search-form').find('input').serialize();
                if(url.indexOf('?')>0){
                    url += '&' + query;
                }else{
                    url += '?' + query;
                }

                window.location.href = url;
            });

            //回车自动提交
            $('.search-form').find('input').keyup(function(event){
                if(event.keyCode===13){
                    $("#search").click();
                }
            });

            //导航高亮
            highlight_subnav("{:U('index')}");
        });
    </script>
</block>
